<!DOCTYPE html>












  


<html class="theme-next gemini use-motion" lang="zh-CN">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">












  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.2.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=7.2.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=7.2.0">


  <link rel="mask-icon" href="/images/logo.svg?v=7.2.0" color="#222">






<link rel="stylesheet" href="/css/main.css?v=7.2.0">






<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.7.0">








<script id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '7.2.0',
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
    back2top: {"enable":true,"sidebar":true,"scrollpercent":true},
    copycode: {"enable":true,"show_result":true,"style":null},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    search: {
      root: '/',
      path: 'search.xml'
    },
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    }
  };
</script>

  <meta name="description" content="说一下思路：ATM的主要功能是存钱，取钱，转账，查询，交易明细。查询，需要登录后才能查询。存钱，要怎样才能存钱？起码需要一个账户，然后存钱的金额不能是负数。取钱，取钱的金额不能为负却不能大于本金。转账，要怎样才能进行转账？转账需要两个账户，还需要转账的金额（金额不能为负数，不能大于本金）。交易明细，记录各各操作的内容，账号及金额附上时间。源码如下，数据库是SQL SERVER 2005，数据库版本">
<meta name="keywords" content="源码,c#ATm">
<meta property="og:type" content="article">
<meta property="og:title" content="csharp三层架构之ATM附源码及数据库文件">
<meta property="og:url" content="http://yoursite.com/2019/c/csharp三层架构之ATM附源码及数据库文件/index.html">
<meta property="og:site_name" content="Evian Z">
<meta property="og:description" content="说一下思路：ATM的主要功能是存钱，取钱，转账，查询，交易明细。查询，需要登录后才能查询。存钱，要怎样才能存钱？起码需要一个账户，然后存钱的金额不能是负数。取钱，取钱的金额不能为负却不能大于本金。转账，要怎样才能进行转账？转账需要两个账户，还需要转账的金额（金额不能为负数，不能大于本金）。交易明细，记录各各操作的内容，账号及金额附上时间。源码如下，数据库是SQL SERVER 2005，数据库版本">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20190511025803651.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20190511025906101.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20190511030059925.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20190511030318166.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20190511030604463.PNG">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20190511032343721.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0lfVGVuS2Fp,size_16,color_FFFFFF,t_70">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20190511034426550.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0lfVGVuS2Fp,size_16,color_FFFFFF,t_70">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20190511032636340.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0lfVGVuS2Fp,size_16,color_FFFFFF,t_70">
<meta property="og:updated_time" content="2019-11-16T02:42:30.486Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="csharp三层架构之ATM附源码及数据库文件">
<meta name="twitter:description" content="说一下思路：ATM的主要功能是存钱，取钱，转账，查询，交易明细。查询，需要登录后才能查询。存钱，要怎样才能存钱？起码需要一个账户，然后存钱的金额不能是负数。取钱，取钱的金额不能为负却不能大于本金。转账，要怎样才能进行转账？转账需要两个账户，还需要转账的金额（金额不能为负数，不能大于本金）。交易明细，记录各各操作的内容，账号及金额附上时间。源码如下，数据库是SQL SERVER 2005，数据库版本">
<meta name="twitter:image" content="https://img-blog.csdnimg.cn/20190511025803651.png">



  <link rel="alternate" href="/atom.xml" title="Evian Z" type="application/atom+xml">



  
  
  <link rel="canonical" href="http://yoursite.com/2019/c/csharp三层架构之ATM附源码及数据库文件/">



<script id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  
  <title>csharp三层架构之ATM附源码及数据库文件 | Evian Z</title>
  












  <noscript>
  <style>
  .use-motion .motion-element,
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-title { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>
<a href="https://github.com/Hzrj" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewbox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"/><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Evian Z</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <h1 class="site-subtitle" itemprop="description">别浪费时间，致自己</h1>
      
    
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">

    
    
      
    

    
      
    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-about">

    
    
      
    

    
      
    

    <a href="/about/" rel="section"><i class="menu-item-icon fa fa-fw fa-user"></i> <br>关于</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">

    
    
      
    

    
      
    

    <a href="/tags/" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签<span class="badge">28</span></a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">

    
    
      
    

    
      
    

    <a href="/categories/" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类<span class="badge">8</span></a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">

    
    
      
    

    
      
    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档<span class="badge">19</span></a>

  </li>

      
      
        <li class="menu-item menu-item-search">
          <a href="javascript:;" class="popup-trigger">
          
            <i class="menu-item-icon fa fa-search fa-fw"></i> <br>搜索</a>
        </li>
      
    </ul>
  

  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
            

          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
      

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/c/csharp三层架构之ATM附源码及数据库文件/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Evian Z">
      <meta itemprop="description" content="Evian 交流群 799983232">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Evian Z">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">csharp三层架构之ATM附源码及数据库文件

              
            
          </h2>
        

        <div class="post-meta">

          
          
          

          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2019-07-29 23:47:15" itemprop="dateCreated datePublished" datetime="2019-07-29T23:47:15+08:00">2019-07-29</time>
            </span>
          

          
            

            
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2019-11-16 10:42:30" itemprop="dateModified" datetime="2019-11-16T10:42:30+08:00">2019-11-16</time>
              </span>
            
          

          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/c/" itemprop="url" rel="index"><span itemprop="name">c#</span></a></span>

                
                
              
            </span>
          

          
          

          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
                 热度： 
                <span class="busuanzi-value" id="busuanzi_value_page_pv"></span>
              </span>
            </span>
          

          

          
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
              
                <span class="post-meta-item-text">本文字数：</span>
              
              <span title="本文字数">27k</span>
            </span>
          

          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
              
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              
              <span title="阅读时长">34 分钟</span>
            </span>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>这是我之前拿来交期末作业的作品<br>这就分享一下下载链接，和接下来的博文<br>下载链接可以直接下载<br>博文可以传阅，欢迎大佬评论。<br>这是百度网盘的下载地址<br><a href="https://pan.baidu.com/s/1w0pdNb3E4szmq2zHEbrMsA" target="_blank" rel="noopener">https://pan.baidu.com/s/1w0pdNb3E4szmq2zHEbrMsA</a></p>
<p>首先这个ATM是使用三层架构来写的，关于三层架构我是在csdn上学的。<br>想要具体了解三层架构的话可以游览一下链接。其次需要了解三层架构的相互之间的关系及引用。</p>
<blockquote>
<p><a href="https://www.cnblogs.com/liuqifeng/p/9150254.html" target="_blank" rel="noopener">https://www.cnblogs.com/liuqifeng/p/9150254.html</a></p>
</blockquote>
<p>最后才开始以下的实践。</p>
<hr>
<p>说一下思路：<br>ATM的主要功能是存钱，取钱，转账，查询，交易明细。</p>
<p>还有就是我这个设计数据库的时候没有考虑周到，给的数据类型时整型的。<br>这是我的失误，你们可以设计成浮点的类型。</p>
<p>查询，需要登录后才能查询。<br>存钱，要怎样才能存钱？起码需要一个账户，然后存钱的金额不能是负数。<br>取钱，取钱的金额不能为负却不能大于本金。<br>转账，要怎样才能进行转账？转账需要两个账户，还需要转账的金额（金额不能为负数，不能大于本金）。<br>交易明细，记录各各操作的内容，账号及金额附上时间。</p>
<p>先贴数据库的图<br>这是用户表字段设计<br><img src="https://img-blog.csdnimg.cn/20190511025803651.png" alt="在这里插入图片描述"></p>
<p>这是用户表的数据<br><img src="https://img-blog.csdnimg.cn/20190511025906101.png" alt="在这里插入图片描述"><br>这是数据表字段的设计，SFZ是用来找回密码的，MONEY是用来储存钱的，<br>RECORD是用来记录交易明细的。<br><img src="https://img-blog.csdnimg.cn/20190511030059925.png" alt="在这里插入图片描述"><br>这是数据表的数据<br><img src="https://img-blog.csdnimg.cn/20190511030318166.png" alt="在这里插入图片描述"><br>这是方案里的项目，建四个项目，以及各类，窗体。<br>他们之间的引用关系在上文的链接中有详细解说。<br><img src="https://img-blog.csdnimg.cn/20190511030604463.PNG" alt="在这里插入图片描述"></p>
<p>MODEL项目里的model.cs代码如下<br> <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">using System;</span><br><span class="line">using System.Collections.Generic;</span><br><span class="line">using System.Linq;</span><br><span class="line">using System.Text;</span><br><span class="line">//bll引用ui，和dal</span><br><span class="line">//ui引用bll，moodel</span><br><span class="line">//dal引用model 和using</span><br><span class="line">namespace MODEL</span><br><span class="line">&#123;</span><br><span class="line">    public class model</span><br><span class="line">    &#123;</span><br><span class="line">        public  string id &#123; get; set; &#125;</span><br><span class="line">        public  string pwd &#123; get; set; &#125;</span><br><span class="line">        public  string sfz &#123; get; set; &#125;</span><br><span class="line">        public string money &#123; get; set; &#125;</span><br><span class="line">        public string record &#123; get; set; &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>DAL项目中的dal.cs代码如下</p>
 <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br></pre></td><td class="code"><pre><span class="line">using System;</span><br><span class="line">using System.Collections.Generic;</span><br><span class="line">using System.Linq;</span><br><span class="line">using System.Text;</span><br><span class="line">using System.Data.SqlClient;</span><br><span class="line">using MODEL;</span><br><span class="line"></span><br><span class="line">namespace DAL</span><br><span class="line">&#123;</span><br><span class="line">    public class dal</span><br><span class="line">    &#123;</span><br><span class="line">        string count = &quot;server=.;DATABASE=MyAtm;Integrated Security=true;&quot;;//连接数据库字符串</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        /*登陆*/</span><br><span class="line">        public model  select(string ID, string PWD)</span><br><span class="line">        &#123; </span><br><span class="line">            model mm = null;</span><br><span class="line">            try</span><br><span class="line">            &#123;</span><br><span class="line">                SqlConnection con=new SqlConnection(count);</span><br><span class="line">                con.Open();</span><br><span class="line">                //string sql = &quot;select * from data where id=&apos;&quot;+ID+&quot;&apos;&quot;;</span><br><span class="line">                SqlCommand cmd = new SqlCommand(&quot;select * from userr WHERE ID=&apos;&quot;+ID+&quot;&apos;&quot;,con);</span><br><span class="line">                SqlDataReader dr=cmd.ExecuteReader();</span><br><span class="line">                if (dr.Read())</span><br><span class="line">                &#123;</span><br><span class="line">                    if (mm == null) //这个必须写</span><br><span class="line">                    &#123;</span><br><span class="line">                        mm = new model();</span><br><span class="line">                    &#125;</span><br><span class="line">                    mm.id = dr[&quot;ID&quot;].ToString().Trim();</span><br><span class="line">                    mm.pwd = dr[&quot;pwd&quot;].ToString().Trim();</span><br><span class="line">                &#125;</span><br><span class="line">                con.Close(); </span><br><span class="line">            &#125;</span><br><span class="line">            catch (Exception ex)&#123;</span><br><span class="line">            &#125;</span><br><span class="line">            return mm;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        /*修改密码*/</span><br><span class="line">        public model update(string ID, string SFZ,string PWD)</span><br><span class="line">        &#123;</span><br><span class="line">            model mm = null;</span><br><span class="line">            try</span><br><span class="line">            &#123;</span><br><span class="line">                SqlConnection con = new SqlConnection(count);</span><br><span class="line">                con.Open();</span><br><span class="line">                string sql = &quot;select * from data where id=&apos;&quot; + ID + &quot;&apos;&quot;;</span><br><span class="line">                SqlCommand cmd = new SqlCommand(sql, con);</span><br><span class="line">                SqlDataReader dr = cmd.ExecuteReader();</span><br><span class="line">                if (dr.Read())</span><br><span class="line">                &#123;</span><br><span class="line">                    if (mm == null)</span><br><span class="line">                    &#123;</span><br><span class="line">                        mm = new model();</span><br><span class="line">                    &#125;</span><br><span class="line">                    mm.id = dr[&quot;id&quot;].ToString().Trim();</span><br><span class="line">                    mm.sfz = dr[&quot;sfz&quot;].ToString().Trim();</span><br><span class="line">                    dr.Close();</span><br><span class="line">                    string sql0 = &quot;update userr set pwd=&apos;&quot; + PWD + &quot;&apos;where id=&apos;&quot; + ID + &quot;&apos;&quot;;</span><br><span class="line">                    SqlCommand cmd1 = new SqlCommand(sql0, con);</span><br><span class="line">                    int n = cmd1.ExecuteNonQuery();</span><br><span class="line">                    mm.pwd = PWD;</span><br><span class="line">                    con.Close();</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">            catch (Exception ex)&#123;</span><br><span class="line">            &#125;</span><br><span class="line">            return mm;</span><br><span class="line">        &#125;</span><br><span class="line">       </span><br><span class="line">        /*查询余额*/</span><br><span class="line">        public model money_select(string ID)//money</span><br><span class="line">        &#123;</span><br><span class="line">            model mm = new model();</span><br><span class="line">            SqlConnection con = new SqlConnection(count);</span><br><span class="line">            string sql = &quot;select * from data where id=&apos;&quot;+ID+&quot;&apos;&quot;;</span><br><span class="line">            con.Open();</span><br><span class="line">            SqlCommand cmd = new SqlCommand(sql,con);</span><br><span class="line">            SqlDataReader dr=cmd.ExecuteReader();</span><br><span class="line">            if (dr.Read())</span><br><span class="line">            &#123;</span><br><span class="line">                if (mm==null)</span><br><span class="line">                &#123;</span><br><span class="line">                    mm = new model();</span><br><span class="line">                &#125;</span><br><span class="line">                mm.money=dr[&quot;money&quot;].ToString().Trim();</span><br><span class="line">            &#125;</span><br><span class="line">            con.Close();</span><br><span class="line">            return mm;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        /*取款*/</span><br><span class="line">        public int i=0;</span><br><span class="line">        public   string DT=&quot;&quot;;</span><br><span class="line">        /*用来储存当前操作的时间，与金额*/</span><br><span class="line">        public model draw(string ID,string DRAW) </span><br><span class="line">        &#123;</span><br><span class="line">            model mm = null;</span><br><span class="line">            string DT_sql = &quot;select * from DATA where id=&apos;&quot;+ID+&quot;&apos;&quot;;</span><br><span class="line">            SqlConnection DT_con = new SqlConnection(count);</span><br><span class="line">            DT_con.Open();</span><br><span class="line">            SqlCommand DT_cmd = new SqlCommand(DT_sql, DT_con);</span><br><span class="line">            SqlDataReader DT_dr = DT_cmd.ExecuteReader();</span><br><span class="line">            model i_mm=new model();</span><br><span class="line">            if (DT_dr.HasRows)</span><br><span class="line">            &#123;</span><br><span class="line">                DT_dr.Read();</span><br><span class="line">                /*-----------先读取之前转账的信息------------*/</span><br><span class="line">                DT += DT_dr[&quot;RECORD&quot;].ToString().Trim();</span><br><span class="line">                i_mm.money = DT_dr[&quot;MONEY&quot;].ToString().Trim();</span><br><span class="line"></span><br><span class="line">            &#125;</span><br><span class="line">            DT_dr.Close();</span><br><span class="line">            DT_con.Close();</span><br><span class="line">            if (DRAW == &quot;&quot; || Convert.ToInt32(DRAW) &gt; Convert.ToInt32(i_mm.money))</span><br><span class="line">            &#123; </span><br><span class="line">                //model i_mm = null;</span><br><span class="line">                mm = i_mm;</span><br><span class="line">                return mm;</span><br><span class="line">            &#125;</span><br><span class="line">            else</span><br><span class="line">            &#123;</span><br><span class="line">                DT += &quot;\n&quot; + DateTime.Now.ToString(&quot;yyy-M-d H:m:s&quot;);</span><br><span class="line">                SqlConnection con = new SqlConnection(count);</span><br><span class="line">                con.Open();</span><br><span class="line">                string sql = &quot;select * from data where id=&apos;&quot; + ID + &quot;&apos;&quot;;//这个查询账号的信息，再进行读取余额</span><br><span class="line">                SqlCommand cmd = new SqlCommand(sql, con);</span><br><span class="line">                SqlDataReader dr = cmd.ExecuteReader();</span><br><span class="line"></span><br><span class="line">                if (dr.Read())</span><br><span class="line">                &#123;</span><br><span class="line">                    i = Convert.ToInt32(dr[&quot;money&quot;].ToString().Trim());//自己的本钱/</span><br><span class="line">                &#125;</span><br><span class="line">                con.Close();</span><br><span class="line">                int k = i - Convert.ToInt32(DRAW);//自己的本钱减去要取出来的钱，然后把k更新到数据可以里</span><br><span class="line">                //2018-12-6 14:3:53已取出100  2018-12-6 14:6:24 已取出10元</span><br><span class="line">                DT += &quot; 已取出&quot; + DRAW + &quot;元&quot;;</span><br><span class="line">                string sqlup = &quot;update data set money=&apos;&quot; + k + &quot;&apos;,RECORD=&apos;&quot; + DT + &quot;&apos;where id=&apos;&quot; + ID + &quot;&apos;&quot;;//执行sql语句</span><br><span class="line">                //string sql02 = &quot;update DATA set mory=&apos;&quot; + k + &quot;&apos;,RECORD=&apos;&quot; + NOW + &quot;&apos;where ID=&apos;&quot; + textBox1.Text.Trim() + &quot;&apos;&quot;;</span><br><span class="line">                con.Open();</span><br><span class="line">                SqlCommand cmdup = new SqlCommand(sqlup, con);</span><br><span class="line">                int n = cmdup.ExecuteNonQuery();</span><br><span class="line">                con.Close();</span><br><span class="line">                mm = null;</span><br><span class="line">                mm = new model();</span><br><span class="line">                mm.money = Convert.ToString(i);</span><br><span class="line">                //要把已经计算好的金额更新到数据库中</span><br><span class="line">                return mm;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        /*储存*/</span><br><span class="line">        public model Storage(string ID, string Money)</span><br><span class="line">        &#123;</span><br><span class="line">            string DT_sql = &quot;select * from DATA&quot;;</span><br><span class="line">            SqlConnection DT_con = new SqlConnection(count);</span><br><span class="line">            DT_con.Open();</span><br><span class="line">            SqlCommand DT_cmd = new SqlCommand(DT_sql, DT_con);</span><br><span class="line">            SqlDataReader DT_dr = DT_cmd.ExecuteReader();</span><br><span class="line">            int m = 0;</span><br><span class="line">            if (DT_dr.HasRows)</span><br><span class="line">            &#123;</span><br><span class="line">                DT_dr.Read();</span><br><span class="line">                /*-----------先读取之前转账的信息------------*/</span><br><span class="line">                DT += DT_dr[&quot;RECORD&quot;].ToString().Trim();</span><br><span class="line">                m = Convert.ToInt32(DT_dr[&quot;MONEY&quot;].ToString().Trim());</span><br><span class="line"></span><br><span class="line">            &#125;</span><br><span class="line">            DT_dr.Close();</span><br><span class="line">            DT_con.Close();</span><br><span class="line"></span><br><span class="line">            DT += &quot;\n&quot; + DateTime.Now.ToString(&quot;yyy-M-d H:m:s&quot;);</span><br><span class="line">            if (Money == &quot;&quot;)</span><br><span class="line">            &#123;</span><br><span class="line">                model i_mm = null;</span><br><span class="line">                return i_mm;</span><br><span class="line">            &#125;</span><br><span class="line">            else</span><br><span class="line">            &#123;</span><br><span class="line">                 //model mm = new model();</span><br><span class="line">                model mm = null;</span><br><span class="line">                SqlConnection con = new SqlConnection(count);</span><br><span class="line">                con.Open();</span><br><span class="line">                string sql = &quot;select * from data where id=&apos;&quot; + ID + &quot;&apos;&quot;;//这个查询账号的信息，再进行读取余额</span><br><span class="line">                SqlCommand cmd = new SqlCommand(sql, con);</span><br><span class="line">                SqlDataReader dr = cmd.ExecuteReader();</span><br><span class="line"></span><br><span class="line">                if (dr.Read())</span><br><span class="line">                &#123;</span><br><span class="line">                    i = Convert.ToInt32(dr[&quot;money&quot;].ToString().Trim());//自己的本钱/</span><br><span class="line">                &#125;</span><br><span class="line">                con.Close();</span><br><span class="line">                int k = i + Convert.ToInt32(Money);//自己的本钱减去要取出来的钱，然后把k更新到数据可以里</span><br><span class="line">                DT += &quot; 已存入&quot; + Money + &quot;元&quot;;</span><br><span class="line">                string sqlup = &quot;update data set money=&apos;&quot; + k + &quot;&apos;,RECORD=&apos;&quot;+DT+&quot;&apos;where id=&apos;&quot; + ID + &quot;&apos;&quot;;//执行sql语句</span><br><span class="line">                con.Open();</span><br><span class="line">                SqlCommand cmdup = new SqlCommand(sqlup, con);</span><br><span class="line">                int n = cmdup.ExecuteNonQuery();</span><br><span class="line">                con.Close();</span><br><span class="line">                mm = null;</span><br><span class="line">                mm = new model();</span><br><span class="line">                mm.money = Convert.ToString(k);</span><br><span class="line">                //要把已经计算好的金额更新到数据库中</span><br><span class="line">                return mm;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        /*转账*//*没有卡号能减少自己的本金，没有金额会报错*/</span><br><span class="line">        int n;</span><br><span class="line">        public model T_accounts(string ID, string YouID, string Ta)</span><br><span class="line">        &#123;</span><br><span class="line">            /*有这账号，没有金额报错，会报错*///ok</span><br><span class="line">            /*，没有账号，会提示没有这个账号，但是有金额可以转账成功*/</span><br><span class="line">            </span><br><span class="line">            string Ta_sql = &quot;select * from DATA&quot;;</span><br><span class="line">            SqlConnection Ta_con = new SqlConnection(count);</span><br><span class="line">            Ta_con.Open();</span><br><span class="line">            SqlCommand Ta_cmd = new SqlCommand(Ta_sql, Ta_con);</span><br><span class="line">            SqlDataReader Ta_dr = Ta_cmd.ExecuteReader();</span><br><span class="line">            int m = 0;</span><br><span class="line">            if (Ta_dr.HasRows)</span><br><span class="line">            &#123;</span><br><span class="line">                Ta_dr.Read();</span><br><span class="line">                /*-----------先读取之前转账的信息------------*/</span><br><span class="line">                DT += Ta_dr[&quot;RECORD&quot;].ToString().Trim();</span><br><span class="line">                m = Convert.ToInt32(Ta_dr[&quot;MONEY&quot;].ToString().Trim());</span><br><span class="line">            &#125;</span><br><span class="line">            Ta_dr.Close();</span><br><span class="line">            Ta_con.Close();</span><br><span class="line"></span><br><span class="line">            DT += &quot;\n&quot; + DateTime.Now.ToString(&quot;yyy-M-d H:m:s&quot;);</span><br><span class="line">            if (Ta == &quot;&quot;||YouID==&quot;&quot; ||Convert.ToInt32(Ta) &gt; Convert.ToInt32(m))</span><br><span class="line">            &#123;</span><br><span class="line">                model mm = null;</span><br><span class="line">                return mm;</span><br><span class="line">            &#125;</span><br><span class="line">            else</span><br><span class="line">            &#123;</span><br><span class="line">                model mm = new model();</span><br><span class="line">                mm.id = YouID;</span><br><span class="line">                SqlConnection con = new SqlConnection(count);</span><br><span class="line">                con.Open();</span><br><span class="line">                string sql = &quot;select * from data where id=&apos;&quot; + ID + &quot;&apos;&quot;;</span><br><span class="line">                SqlCommand cmd = new SqlCommand(sql, con);</span><br><span class="line">                SqlDataReader dr = cmd.ExecuteReader();</span><br><span class="line">                if (dr.Read())</span><br><span class="line">                &#123;</span><br><span class="line">                    mm.money = dr[&quot;money&quot;].ToString().Trim();//获取自己的余额</span><br><span class="line">                    dr.Close();</span><br><span class="line">                &#125;</span><br><span class="line">                /*n相当于自己的余额减去转账的金额--然后把这个n更新到数据库里面*/</span><br><span class="line">                DT += &quot; 已转入&quot; + YouID + &quot;：&quot;+Ta+&quot;元&quot;;</span><br><span class="line">                n = Convert.ToInt32(mm.money) - Convert.ToInt32(Ta);</span><br><span class="line">                string n_sql = &quot;update data set money=&apos;&quot; + n + &quot;&apos;,RECORD=&apos;&quot;+DT+&quot;&apos;where id=&apos;&quot; + ID + &quot;&apos;&quot;;</span><br><span class="line">                SqlCommand n_cmd = new SqlCommand(n_sql, con);</span><br><span class="line">                int i = n_cmd.ExecuteNonQuery();</span><br><span class="line"></span><br><span class="line">                string m_sql = &quot;select * from data where id=&apos;&quot; + YouID + &quot;&apos;&quot;;</span><br><span class="line">                SqlCommand m_cmd = new SqlCommand(m_sql, con);</span><br><span class="line">                SqlDataReader m_dr = m_cmd.ExecuteReader();</span><br><span class="line">                if (m_dr.Read())</span><br><span class="line">                &#123;</span><br><span class="line">                    mm.money = &quot;&quot;;</span><br><span class="line">                    mm.money = m_dr[&quot;money&quot;].ToString().Trim();//获取自己的余额</span><br><span class="line">                &#125;</span><br><span class="line">                m_dr.Close();</span><br><span class="line">                int k_1 = Convert.ToInt32(mm.money);</span><br><span class="line">                int k_2= Convert.ToInt32(Ta);</span><br><span class="line">                k_1 +=  k_2;</span><br><span class="line">                string q_sql = &quot;update data set money=&apos;&quot; + k_1 + &quot;&apos;where id=&apos;&quot; + YouID + &quot;&apos;&quot;;</span><br><span class="line">                SqlCommand q_cmd = new SqlCommand(q_sql, con);</span><br><span class="line">                int j = q_cmd.ExecuteNonQuery();</span><br><span class="line">                con.Close();</span><br><span class="line">                return mm;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        /*记录*/</span><br><span class="line">        public model record(string ID)</span><br><span class="line">        &#123;</span><br><span class="line">            model mm = new model();</span><br><span class="line">            SqlConnection con = new SqlConnection(count);</span><br><span class="line">            string sql = &quot;select * from data where id=&apos;&quot; + ID + &quot;&apos;&quot;;</span><br><span class="line">            con.Open();</span><br><span class="line">            SqlCommand cmd = new SqlCommand(sql, con);</span><br><span class="line">            SqlDataReader dr = cmd.ExecuteReader();</span><br><span class="line">            if (dr.Read())</span><br><span class="line">            &#123;</span><br><span class="line">                if (mm == null)</span><br><span class="line">                &#123;</span><br><span class="line">                    mm = new model();</span><br><span class="line">                &#125;</span><br><span class="line">                mm.record = dr[&quot;RECORD&quot;].ToString().Trim();</span><br><span class="line">            &#125;</span><br><span class="line">            con.Close();</span><br><span class="line">            return mm;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>BLL中的bll.cs代码如下</p>
 <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br></pre></td><td class="code"><pre><span class="line">using System;</span><br><span class="line">using System.Collections.Generic;</span><br><span class="line">using System.Linq;</span><br><span class="line">using System.Text;</span><br><span class="line">using MODEL;</span><br><span class="line">namespace BLL</span><br><span class="line">&#123;</span><br><span class="line">    public class bll</span><br><span class="line">    &#123;</span><br><span class="line">        //登录方法</span><br><span class="line">        public int select(string ID, string PWD)</span><br><span class="line">        &#123;</span><br><span class="line">            DAL.dal dal = new DAL.dal();</span><br><span class="line">            model mm = dal.select(ID, PWD);</span><br><span class="line">            if (mm != null &amp;&amp; mm.id == ID)</span><br><span class="line">            &#123;</span><br><span class="line">                if (mm.pwd == PWD)</span><br><span class="line">                &#123;</span><br><span class="line">                    return 0;//登陆成功 </span><br><span class="line">                &#125;</span><br><span class="line">                return 1;//密码错误</span><br><span class="line">            &#125;</span><br><span class="line">            return 2;//没有这个账号</span><br><span class="line">        &#125;</span><br><span class="line">        //修改密码</span><br><span class="line">        public int update(string ID, string SFZ,string PWD)</span><br><span class="line">        &#123;</span><br><span class="line">            DAL.dal dal = new DAL.dal();</span><br><span class="line">            model mm = dal.update(ID,SFZ,PWD);</span><br><span class="line">            if (mm !=null &amp;&amp; mm.id==ID)</span><br><span class="line">            &#123;</span><br><span class="line">                if (mm.sfz==SFZ)</span><br><span class="line">                &#123;</span><br><span class="line">                    return 0;</span><br><span class="line">                &#125;</span><br><span class="line">                return 1;</span><br><span class="line">            &#125;</span><br><span class="line">            return 2;</span><br><span class="line">        &#125;</span><br><span class="line">        //查询余额</span><br><span class="line">        public string  money_select(string ID) </span><br><span class="line">        &#123;</span><br><span class="line">            DAL.dal dal = new DAL.dal();</span><br><span class="line">            model mm = dal.money_select(ID);</span><br><span class="line">            return mm.money; //余额</span><br><span class="line">        &#125;</span><br><span class="line">        //取款</span><br><span class="line">        public int draw(string ID,string DRAW) </span><br><span class="line">        &#123;</span><br><span class="line">            DAL.dal dal = new DAL.dal();</span><br><span class="line">            model mm = dal.draw(ID,DRAW);</span><br><span class="line">            if (DRAW == &quot;&quot;)</span><br><span class="line">            &#123;</span><br><span class="line">                return 2;//不能为空</span><br><span class="line">            &#125;</span><br><span class="line">            else</span><br><span class="line">            &#123;</span><br><span class="line">                BLL.bll bll = new BLL.bll();</span><br><span class="line">                if (DRAW!=null)</span><br><span class="line">                &#123;</span><br><span class="line">                    if(Convert.ToInt32(DRAW)&gt;Convert.ToInt32(mm.money))//100&gt;1</span><br><span class="line">                    &#123;</span><br><span class="line">                        return 1;</span><br><span class="line">                    &#125;</span><br><span class="line">                    return 0;</span><br><span class="line">                    //要取款的金额不能大于余额或小于负数</span><br><span class="line">                &#125;</span><br><span class="line">                return 2;</span><br><span class="line">            &#125;</span><br><span class="line">            //取款成功</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        /*储存*/</span><br><span class="line">        public int Storage(string ID, string Money)</span><br><span class="line">        &#123;</span><br><span class="line">            DAL.dal dal = new DAL.dal();</span><br><span class="line">            model mm = dal.Storage(ID,Money);</span><br><span class="line">            if (Money == &quot;&quot;)</span><br><span class="line">            &#123;</span><br><span class="line">                return 1;//不能为空</span><br><span class="line">            &#125;</span><br><span class="line">            else</span><br><span class="line">            &#123;</span><br><span class="line">                //int i = Convert.ToInt32(mm.money);</span><br><span class="line">                BLL.bll bll = new BLL.bll();</span><br><span class="line">                //int m = Convert.ToInt32(bll.money_select(ID));</span><br><span class="line">                return 0;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        /*转账*/</span><br><span class="line">        public int T_accounts(string ID, string YouID, string Ta)</span><br><span class="line">        &#123;</span><br><span class="line">            DAL.dal dal = new DAL.dal();</span><br><span class="line">            model mm = dal.T_accounts(ID,YouID,Ta);</span><br><span class="line">            if (Ta==&quot;&quot;&amp;&amp;YouID==&quot;&quot;)</span><br><span class="line">            &#123;</span><br><span class="line">                return 2;//对方帐号和要转账的金额不能为空</span><br><span class="line">            &#125;</span><br><span class="line">            //int i = Convert.ToInt32(mm.money);</span><br><span class="line">            BLL.bll bll = new BLL.bll();</span><br><span class="line">            int m = Convert.ToInt32(bll.money_select(ID));//查询余额</span><br><span class="line">            if(mm!=null&amp;&amp;mm.id==YouID&amp;&amp;Ta!=null&amp;YouID!=null)</span><br><span class="line">            &#123;</span><br><span class="line">                if (Convert.ToInt32(Ta)&gt;m)</span><br><span class="line">                &#123;</span><br><span class="line">                    return 0; //要转账的金额不能大于余额</span><br><span class="line">                &#125; return 1;  //转账成功</span><br><span class="line">            &#125;</span><br><span class="line">            return 2;</span><br><span class="line">            //没有这个账号</span><br><span class="line">          </span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        /*交易明细*/</span><br><span class="line">        public string Record(string ID)</span><br><span class="line">        &#123;</span><br><span class="line">            DAL.dal dal = new DAL.dal();</span><br><span class="line">            model mm = dal.record(ID);</span><br><span class="line">            return mm.record;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>ul层的窗体界面如图<br><img src="https://img-blog.csdnimg.cn/20190511032343721.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0lfVGVuS2Fp,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"><br><img src="https://img-blog.csdnimg.cn/20190511034426550.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0lfVGVuS2Fp,size_16,color_FFFFFF,t_70" alt><br><img src="https://img-blog.csdnimg.cn/20190511032636340.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0lfVGVuS2Fp,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"><br>接下来是ul层中form1（登陆）的代码如下</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br></pre></td><td class="code"><pre><span class="line">using System;</span><br><span class="line">using System.Collections.Generic;</span><br><span class="line">using System.ComponentModel;</span><br><span class="line">using System.Data;</span><br><span class="line">using System.Drawing;</span><br><span class="line">using System.Linq;</span><br><span class="line">using System.Text;</span><br><span class="line">using System.Windows.Forms;</span><br><span class="line">using MODEL;</span><br><span class="line"></span><br><span class="line">namespace 三层架构之ATM</span><br><span class="line">&#123;</span><br><span class="line">    public partial class Form1 : Form</span><br><span class="line">    &#123;</span><br><span class="line">        public Form1()</span><br><span class="line">        &#123;</span><br><span class="line">            InitializeComponent();</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        private void button1_Click(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            label1.Text = &quot;卡号：&quot;;</span><br><span class="line">            label2.Text = &quot;密码：&quot;;</span><br><span class="line">            button1.Text = &quot;登陆&quot;;</span><br><span class="line">            button2.Text = &quot;找回&quot;;</span><br><span class="line">            string ID = textBox1.Text;</span><br><span class="line">            string PWD = textBox2.Text;</span><br><span class="line">            //BLL.USERADO bb = new BLL.USERADO();//先实例化逻辑层</span><br><span class="line">            BLL.bll bb=new BLL.bll();</span><br><span class="line">            int uu = bb.select(ID,PWD); </span><br><span class="line">            if (uu==0)</span><br><span class="line">	        &#123;</span><br><span class="line">                Form3 f3 = new Form3(textBox1.Text);</span><br><span class="line">                label1.Visible = false;</span><br><span class="line">                label2.Visible = false;</span><br><span class="line">                button1.Visible = false;</span><br><span class="line">                button2.Visible = false;</span><br><span class="line">                textBox1.Visible = false;</span><br><span class="line">                textBox2.Visible = false;</span><br><span class="line">                f3.MdiParent = this;</span><br><span class="line">                f3.Show();</span><br><span class="line">                MessageBox.Show(&quot;登陆成功&quot;);</span><br><span class="line">	        &#125;</span><br><span class="line">            else if(uu==1)</span><br><span class="line">            &#123;</span><br><span class="line">                MessageBox.Show(&quot;密码错误&quot;);</span><br><span class="line">            &#125;</span><br><span class="line">            else if(uu==2)</span><br><span class="line">            &#123;</span><br><span class="line">                MessageBox.Show(&quot;没有这个账号&quot;);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        private void button2_Click(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            label1.Visible = false;</span><br><span class="line">            label2.Visible = false;</span><br><span class="line">            button1.Visible = false;</span><br><span class="line">            button2.Visible = false;</span><br><span class="line">            textBox1.Visible = false;</span><br><span class="line">            textBox2.Visible = false;</span><br><span class="line">            Form2 f2 = new Form2(this);</span><br><span class="line">            f2.MdiParent = this;</span><br><span class="line">            f2.Show();</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        private void Form1_Load(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            this.IsMdiContainer = true;</span><br><span class="line">            textBox2.UseSystemPasswordChar = true;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        private void button3_Click(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            label1.Visible = false;</span><br><span class="line">            label2.Visible = false;</span><br><span class="line">            button1.Visible = false;</span><br><span class="line">            button2.Visible = false;</span><br><span class="line">            textBox1.Visible = false;</span><br><span class="line">            textBox2.Visible = false;</span><br><span class="line">            Form2 f2 = new Form2();</span><br><span class="line">            f2.Show(this);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>form2(找回)的代码如下</p>
 <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br></pre></td><td class="code"><pre><span class="line">using System;</span><br><span class="line">using System.Collections.Generic;</span><br><span class="line">using System.ComponentModel;</span><br><span class="line">using System.Data;</span><br><span class="line">using System.Drawing;</span><br><span class="line">using System.Linq;</span><br><span class="line">using System.Text;</span><br><span class="line">using System.Windows.Forms;</span><br><span class="line"></span><br><span class="line">namespace 三层架构之ATM</span><br><span class="line">&#123;</span><br><span class="line">    public partial class Form2 : Form</span><br><span class="line">    &#123;</span><br><span class="line">        Form1 _form; </span><br><span class="line">        public Form2()</span><br><span class="line">        &#123;</span><br><span class="line">            InitializeComponent();</span><br><span class="line">            textBox3.UseSystemPasswordChar = true;</span><br><span class="line">        &#125;</span><br><span class="line">        public Form2(Form1 form)</span><br><span class="line">        &#123;</span><br><span class="line">            InitializeComponent();</span><br><span class="line">            _form = form;//得到传过来的Form1实例 </span><br><span class="line">        &#125; </span><br><span class="line">        string txt;</span><br><span class="line">        public Form2(string str)</span><br><span class="line">        &#123;</span><br><span class="line">            InitializeComponent();</span><br><span class="line">            txt = str;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        private void button1_Click(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            //textBox1.Text = txt;</span><br><span class="line">            //textBox1.ReadOnly = true;</span><br><span class="line">            string ID = textBox1.Text;</span><br><span class="line">            string PWD = textBox3.Text;</span><br><span class="line">            string SFZ = textBox2.Text;</span><br><span class="line">            BLL.bll bb = new BLL.bll();</span><br><span class="line">            int uu = bb.update(ID,SFZ,PWD);</span><br><span class="line">            if (uu==0)</span><br><span class="line">            &#123;</span><br><span class="line">                MessageBox.Show(&quot;修改成功&quot;);</span><br><span class="line">            &#125; if (uu == 1)</span><br><span class="line">            &#123;</span><br><span class="line">                MessageBox.Show(&quot;身份证错误&quot;);</span><br><span class="line">            &#125; if (uu == 2)</span><br><span class="line">            &#123;</span><br><span class="line">                MessageBox.Show(&quot;没有这个账号&quot;);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        private void button2_Click(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">          </span><br><span class="line">            Form1 f1=new Form1();</span><br><span class="line">            f1.Owner=this;</span><br><span class="line">            f1.label1.Visible = true;</span><br><span class="line">            f1.label2.Visible = true;</span><br><span class="line">            f1.button1.Visible = true;</span><br><span class="line">            f1.button2.Visible = true;</span><br><span class="line">            f1.textBox1.Visible = true;</span><br><span class="line">            f1.textBox2.Visible = true;</span><br><span class="line">            //button3.Visible = true;</span><br><span class="line">            f1.Show();</span><br><span class="line">            _form.Hide();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>form3(功能)代码如下</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br></pre></td><td class="code"><pre><span class="line">using System;</span><br><span class="line">using System.Collections.Generic;</span><br><span class="line">using System.ComponentModel;</span><br><span class="line">using System.Data;</span><br><span class="line">using System.Drawing;</span><br><span class="line">using System.Linq;</span><br><span class="line">using System.Text;</span><br><span class="line">using System.Windows.Forms;</span><br><span class="line">using MODEL;</span><br><span class="line">namespace 三层架构之ATM</span><br><span class="line">&#123;</span><br><span class="line">    public partial class Form3 : Form</span><br><span class="line">    &#123;</span><br><span class="line">        public Form3()</span><br><span class="line">        &#123;</span><br><span class="line">            InitializeComponent();</span><br><span class="line">        &#125;</span><br><span class="line">        string txt;</span><br><span class="line">        public Form3(string str)</span><br><span class="line">        &#123;</span><br><span class="line">            InitializeComponent();</span><br><span class="line">            txt = str;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        /*查询余额*/</span><br><span class="line">        private void button1_Click(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            label1.Text = &quot;卡号：&quot;;</span><br><span class="line">            label2.Text = &quot;余额：&quot;;</span><br><span class="line">            label2.Visible = true;</span><br><span class="line">            string ID = textBox1.Text;</span><br><span class="line">            textBox2.Visible = true;</span><br><span class="line">            label3.Visible = false;</span><br><span class="line">            textBox3.Visible = false;</span><br><span class="line">            BLL.bll bll = new BLL.bll();</span><br><span class="line">            string uu = bll.money_select(ID);</span><br><span class="line">            textBox2.Text = uu;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        private void Form3_Load(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            textBox1.ReadOnly = true;</span><br><span class="line">            textBox1.Text = txt;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        /*取款*/</span><br><span class="line">        private void button2_Click(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            label1.Text = &quot;卡号：&quot;;</span><br><span class="line">            label2.Text = &quot;金额：&quot;;</span><br><span class="line">            label2.Visible = true;</span><br><span class="line">            label1.Visible = true;</span><br><span class="line">            textBox1.Visible = true;</span><br><span class="line">            textBox1.Text = txt;</span><br><span class="line">            string ID =textBox1.Text;</span><br><span class="line">            string DRAW =textBox2.Text;</span><br><span class="line">            BLL.bll bll = new BLL.bll();</span><br><span class="line">            int uu = bll.draw(ID,DRAW);</span><br><span class="line">            if (uu==0)</span><br><span class="line">            &#123;</span><br><span class="line">                MessageBox.Show(&quot;取款成功&quot;);</span><br><span class="line">            &#125;if(uu==1)</span><br><span class="line">            &#123;</span><br><span class="line">                MessageBox.Show(&quot;输入的金额不能大于余额&quot;);</span><br><span class="line">            &#125;if(uu==2)</span><br><span class="line">            &#123;</span><br><span class="line">                MessageBox.Show(&quot;要取款的金额不能为空&quot;);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        private void button1_MouseLeave(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            textBox2.Text = &quot;&quot;;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        /*存款*/</span><br><span class="line">        private void button3_Click(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            string ID = textBox1.Text;</span><br><span class="line">            string Money = textBox2.Text;</span><br><span class="line">            BLL.bll bll = new BLL.bll();</span><br><span class="line">            int uu = bll.Storage(ID,Money);</span><br><span class="line">            if(uu==0)</span><br><span class="line">            &#123;</span><br><span class="line">                MessageBox.Show(&quot;存款成功&quot;);</span><br><span class="line">            &#125; if (uu == 1)</span><br><span class="line">            &#123;</span><br><span class="line">                MessageBox.Show(&quot;请输入要储存的金额&quot;);</span><br><span class="line">            &#125;</span><br><span class="line">            //int uu=bll.</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        /*转账*/</span><br><span class="line">        private void button4_Click(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            string ID = textBox1.Text;</span><br><span class="line">            string YouID = textBox2.Text;</span><br><span class="line">            string Ta = textBox3.Text;</span><br><span class="line">            BLL.bll bll = new BLL.bll();</span><br><span class="line">            int uu = bll.T_accounts(ID,YouID,Ta);</span><br><span class="line">            if (uu==0)</span><br><span class="line">            &#123;</span><br><span class="line">                MessageBox.Show(&quot;要转账的金额不能大于余额&quot;);</span><br><span class="line">            &#125;if(uu==1)</span><br><span class="line">            &#123;</span><br><span class="line">                MessageBox.Show(&quot;转账成功&quot;);</span><br><span class="line">            &#125;if(uu==2)</span><br><span class="line">            &#123;</span><br><span class="line">                MessageBox.Show(&quot;不存在这个卡号或金额不能为空&quot;);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        /*鼠标进入控件事件*/</span><br><span class="line">        private void button4_MouseEnter(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            label2.Text = &quot;对方卡号：&quot;;</span><br><span class="line">            label2.Visible = true;</span><br><span class="line">            textBox2.Visible = true;</span><br><span class="line">            label3.Text = &quot;金额：&quot;;</span><br><span class="line">            label3.Visible = true;</span><br><span class="line">            textBox3.Visible = true;</span><br><span class="line">            textBox3.Width=100;</span><br><span class="line">            textBox3.Height=21;</span><br><span class="line">        &#125;</span><br><span class="line">        /*鼠标进入控件事件*/</span><br><span class="line">        private void button2_MouseEnter(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            label2.Text = &quot;金额：&quot;;</span><br><span class="line">            label2.Visible = true;</span><br><span class="line">            label3.Visible = false;</span><br><span class="line">            textBox3.Visible = false;</span><br><span class="line">            textBox2.Visible = true;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">             if (e.KeyChar &gt; 0x20)</span><br><span class="line">            &#123;</span><br><span class="line">                try</span><br><span class="line">                &#123;</span><br><span class="line">                    double.Parse(((TextBox)sender).Text + e.KeyChar.ToString());</span><br><span class="line">                &#125;</span><br><span class="line">                catch</span><br><span class="line">                &#123;</span><br><span class="line">                    e.KeyChar = (char)0;   //处理非法字符  </span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        private void textBox3_KeyPress(object sender, KeyPressEventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            if (e.KeyChar &gt; 0x20)</span><br><span class="line">            &#123;</span><br><span class="line">                try</span><br><span class="line">                &#123;</span><br><span class="line">                    double.Parse(((TextBox)sender).Text + e.KeyChar.ToString());</span><br><span class="line">                &#125;</span><br><span class="line">                catch</span><br><span class="line">                &#123;</span><br><span class="line">                    e.KeyChar = (char)0;   //处理非法字符  </span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        private void button3_MouseEnter(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            label2.Text = &quot;金额：&quot;;</span><br><span class="line">            label2.Visible = true;</span><br><span class="line">            label3.Visible = false;</span><br><span class="line">            textBox3.Visible = false;</span><br><span class="line">            textBox2.Visible = true;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        private void button5_Click(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">           </span><br><span class="line">            //textBox3.Size=(201, 67);</span><br><span class="line">            string ID = textBox1.Text;</span><br><span class="line">            model mm = new model();</span><br><span class="line">            BLL.bll bll = new BLL.bll();</span><br><span class="line">            string uu= bll.Record(ID);</span><br><span class="line">            textBox3.Text= uu;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        private void button6_Click(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            this.Close();</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        private void button5_MouseEnter(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            label2.Visible = false;</span><br><span class="line">            textBox2.Visible = false;</span><br><span class="line">            label3.Text = &quot;交易记录&quot;;</span><br><span class="line">            textBox3.Width = 201;</span><br><span class="line">            textBox3.Height = 67;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        private void button5_MouseLeave(object sender, EventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            textBox3.Text = &quot;&quot;;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        private void Form3_FormClosed(object sender, FormClosedEventArgs e)</span><br><span class="line">        &#123;</span><br><span class="line">            System.Environment.Exit(0); //关闭程序</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
      
    </div>

    

    
      
    

    
    
    

    
      <div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center;">
  <img id="wechat_subscriber_qcode" src="/uploads/wechat-qcode.jpg" alt="Evian Z wechat" style="width: 200px; max-width: 100%;">
  <div></div>
</div>

    

    
      
    
    
      <div>
        <div id="reward-container">
  <div>打赏由马云爸爸买单，谢谢请我喝牛奶.</div>
  <button id="reward-button" disable="enable" onclick="var qr = document.getElementById(&quot;qr&quot;); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">

    
      
      
        
      
      <div style="display: inline-block">
        <img src="/images/Alipay red envelope.jpg" alt="Evian Z 支付宝红包">
        <p>支付宝红包</p>
      </div>
    
      
      
        
      
      <div style="display: inline-block">
        <img src="/images/alipay.jpg" alt="Evian Z 支付宝">
        <p>支付宝</p>
      </div>
    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        
          
        
        <div class="post-tags">
          
            <a href="/tags/源码/" rel="tag"># 源码</a>
          
            <a href="/tags/c-ATm/" rel="tag"># c#ATm</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/java/java-抽象类的实现与具体解析-抽象类与接口系列之一/" rel="next" title="java  抽象类的实现与具体解析 抽象类与接口系列之一">
                <i class="fa fa-chevron-left"></i> java  抽象类的实现与具体解析 抽象类与接口系列之一
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2019/java/java-interface（接口）的使用-抽象类与接口系列之二/" rel="prev" title="java interface（接口）的使用 抽象类与接口系列之二">
                java interface（接口）的使用 抽象类与接口系列之二 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
    <div>  
      
          
        
  </div>
  
  
  
  </article>

  </div>


          </div>
          
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      

      <div class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">

          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  
    <img class="site-author-image" itemprop="image" src="/images/avatar.jpg" alt="Evian Z">
  
  <p class="site-author-name" itemprop="name">Evian Z</p>
  <div class="site-description motion-element" itemprop="description">Evian 交流群 799983232</div>
</div>


  <nav class="site-state motion-element">
    
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">19</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
    

    
      
      
      <div class="site-state-item site-state-categories">
        
          
            <a href="/categories/">
          
        
        
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">4</span>
        <span class="site-state-item-name">分类</span>
        </a>
      </div>
    

    
      
      
      <div class="site-state-item site-state-tags">
        
          
            <a href="/tags/">
          
        
        
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">20</span>
        <span class="site-state-item-name">标签</span>
        </a>
      </div>
    
  </nav>



  <div class="feed-link motion-element">
    <a href="/atom.xml" rel="alternate">
      <i class="fa fa-rss"></i>RSS
    </a>
  </div>





  <div class="links-of-author motion-element">
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://github.com/Hzrj" title="GitHub &rarr; https://github.com/Hzrj" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="mailto:1316836373@qq.com" title="E-Mail &rarr; mailto:1316836373@qq.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-E-Mail"></i>E-Mail</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://blog.csdn.net/I_TenKai" title="csdn &rarr; https://blog.csdn.net/I_TenKai" rel="noopener" target="_blank"><i class="fa fa-fw fa-globe"></i>csdn</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://baidu.com" title="baidu &rarr; https://baidu.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-baidu"></i>baidu</a>
      </span>
    
  </div>







          
          
        </div>
      </div>

      
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="298" height="52" src="//music.163.com/outchain/player?type=2&id=33075054&auto=0&height=32"></iframe>		  
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="298" height="52" src="//music.163.com/outchain/player?type=2&id=1354221816&auto=0&height=32"></iframe>
      
        <div class="back-to-top motion-element">
          <i class="fa fa-arrow-up"></i>
          
            <span id="scrollpercent"><span>0</span>%</span>
          
        </div>
      

    </div>
	
  </aside>
  <div id="sidebar-dimmer"></div>
  


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Evian Z</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">站点总字数：</span>
    
    <span title="站点总字数">70k</span>
  

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    
      <span class="post-meta-item-text">站点阅读时长 &asymp;</span>
    
    <span title="站点阅读时长">1:27</span>
  
  <a href="http://www.beian.gov.cn">粤ICP备44522202000153号</a> 
</div>
<!-- 

  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.9.0</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 – <a href="https://theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> v7.2.0</div>

-->


  
  <script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?51920f44b6f27592d202fbbbec94df40";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="post-meta-item-icon">
      <i class="fa fa-user"></i>
    </span>
    <span class="site-uv" title="总访客量">
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
    </span>
  

  
    <span class="post-meta-divider">|</span>
  

  
    <span class="post-meta-item-icon">
      <i class="fa fa-eye"></i>
    </span>
    <span class="site-pv" title="总访问量">
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
    </span>
  
</div>









        
      </div>
    </footer>

    

    

    

    

  </div>

  

<script>
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>
















  
  









  
  <script src="/lib/jquery/index.js?v=3.4.1"></script>

  
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>




  <script src="/js/utils.js?v=7.2.0"></script>

  <script src="/js/motion.js?v=7.2.0"></script>



  
  


  <script src="/js/affix.js?v=7.2.0"></script>

  <script src="/js/schemes/pisces.js?v=7.2.0"></script>




  
  <script src="/js/scrollspy.js?v=7.2.0"></script>
<script src="/js/post-details.js?v=7.2.0"></script>



  <script src="/js/next-boot.js?v=7.2.0"></script>

  

  

  


  













  <script src="/js/local-search.js?v=7.2.0"></script>












<script>
// GET RESPONSIVE HEIGHT PASSED FROM IFRAME

window.addEventListener("message", function(e) {
  var data = e.data;
  if ((typeof data === 'string') && (data.indexOf('ciu_embed') > -1)) {
    var featureID = data.split(':')[1];
    var height = data.split(':')[2];
    $(`iframe[data-feature=${featureID}]`).height(parseInt(height) + 30);
  }
}, false);
</script>



  <script>
    (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      bp.src = (curProtocol === 'https') ? 'https://zz.bdstatic.com/linksubmit/push.js' : 'http://push.zhanzhang.baidu.com/push.js';
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>






  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
